package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class DVDContainer here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class DVDContainer
{
    // instance variables - replace the example below with your own
    private ArrayList<DvD> DVDCollection;
    private ArrayList<String> dvdList;
    /**
     * Constructor for objects of class DVDContainer
     */
    public DVDContainer()
    {
        DVDCollection = new ArrayList<DvD>();
        
    }
    
    public void addDVD(DvD d)
    {
        DVDCollection.add(d);
    }
    
    public DvD createDVD(int id, String title, String artist, String releaseDate)
    {
        DvD d = new DvD(id, title, artist, releaseDate);
        return d;
    }
    
    public DvD findDVD(int id)
    {
        int index = 0;
        boolean found = false;
        while(index < DVDCollection.size() && !found)
        {
            DvD d = DVDCollection.get(index);
            if(d.getId() == id)
            {
                found = true;
            }
            else
            {
                index++;
            }
        }
        if(found)
        {
            return DVDCollection.get(index);
        }
        else
        {
            return null;
        }
    }
    
    public void removeDVD(int id)
    {
        DVDCollection.remove(findDVD(id));
    }
    
    public ArrayList<String> showAllDVDs()
    {
        dvdList = new ArrayList<String>();
        for(DvD listName : DVDCollection)
        {
            dvdList.add(listName.getTitle());
        }
        return dvdList;
    }
}
